package com.jframe.sso.action;

import java.util.ArrayList;
import java.util.List;

import com.jframe.sso.model.LoginLogs;
import com.jframe.sso.model.User;
import com.jframe.sys.controller.ExtendAction;
import com.jframe.sys.controller.utils.DicCache;
import com.jframe.sys.controller.utils.JsBuilder;
import com.jframe.sys.controller.utils.TabmCache;
import com.jframe.sys.webui.Columns;
import com.jframe.sys.webui.Editor;
import com.jframe.sys.webui.Grid;

public class LoginLogsAction extends ExtendAction {
	
	private static String ACTION="loginLogsAction";
	private static String SERVICE="loginLogService";
	private static Class<LoginLogs> CLAZZ=LoginLogs.class;
	
	public void list(){
		//加载数据字典
		List<Columns> frozenColumns = new ArrayList<Columns>();//固定列
		List<Columns> commonColumns = new ArrayList<Columns>();
		//frozenColumns.add(new Columns("ck","",40,""));
		//frozenColumns.add(new Columns("id", "编号", 100,""));
		frozenColumns.add(new Columns("userNo", "账号", 120,""));
		commonColumns.add(new Columns("userName","用户名",120,""));
		frozenColumns.add(new Columns("sessionId", "登陆session", 250,""));
		commonColumns.add(new Columns("ip","登陆ip",180,""));
		commonColumns.add(new Columns("roleId","角色",120,new Editor("combobox",true),TabmCache.getComboboxJson("sm_sys_role")));
		//commonColumns.add(new Columns("memberId","成员",120,""));
		commonColumns.add(new Columns("loginTime","登陆时间",150,""));
		commonColumns.add(new Columns("loginOutTime","退出时间",150,""));
		//commonColumns.add(new Columns("deptId","部门",120,""));
		commonColumns.add(new Columns("isLogin","登陆结果",120,new Editor("combobox",true),DicCache.getComboboxJson("dm_sys_isLogin")));
		Grid grid = new Grid();
		grid.setUrl(this.getUrl(ACTION+".do?method=load"));
		String js = JsBuilder.getJsStr(frozenColumns, commonColumns, grid);
		this.request.setAttribute("js", js);
		this.forward("/jframe/sso/list/loginLogsList.jsp");
	}
	
	public void load(){
		this.baseLoad(SERVICE, CLAZZ, " and userNo=?", " order by id desc", this.curUser.getUserNo());
	}
}
